package offer;

public class offer_0046 {
    public int translateNum(int num) {
        int len;
        String s= ""+num;
        len=s.length();
        int[] dp=new int[len];
        if(len==1) return 1;
        dp[0]=1;
        if(judge(s.charAt(0),s.charAt(1))){
            dp[1]=2;
        }
        else dp[1]=1;
        for(int i=2;i<len;++i){
            dp[i]=dp[i-1];
            if(judge(s.charAt(i-1),s.charAt(i))) dp[i]+=dp[i-2];
        }
        return dp[len-1];
    }
    public boolean judge(char a,char b){
        if(a=='1'){
            return true;
        }
        else if(a=='2'){
            if(b>='0'&&b<='5') return true;
        }
        return false;
    }
}
